package com.cuit.blog.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import com.cuit.blog.entity.User;
import jakarta.transaction.Transactional;

@Mapper
@Transactional
public interface UserMapper {
	List<User> findAll();
	// 通过用户名来进行查询
	User findByName(String username);
	
	User getById(int id);
	
	User getByUsername(String username);
	// 使用java bean传递多个参数，在xml中可以直接使用bean的property name，即#{username}
	int insert(User user);
	
	int delete(int id);
	int deleteByIds(int[] ids);
	
	// 两个参数，第二个参数是java bean，使用的时候需要使用#{user.username}
	int update(int id, User user);
	
	
	/*
    @Insert("insert into t_user(username, email, password) values(#{username}, #{email}, #{pwd})")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int add(User user);

    @Update("update t_user set user_name = #{userName} where id = #{id}")
    int update(User user);

    @Delete("delete from t_user where id = #{id}")
    int remove(int id);

    @Select("select * from t_user where id = #{id}")
    User findById(@Param("id") int id);

    @Select("select * from t_user")
    List<User> findAll();
    */
}
